def isAnagram(word1, word2):
    if len(word1) != len(word2):
        return False
    char_count = {}
    for char in word1:
        if char in char_count:
            char_count[char] += 1
        else:
            char_count[char] = 1
    for char in word2:
        if char in char_count:
            char_count[char] -= 1
        else:
            return False
    for count in char_count.values():
        if count != 0:
            return False
    return True

# === DO NOT modify the code below ===
def main():
    s1 = input()
    s2 = input()
    print(1 if isAnagram(s1, s2) else 0)
    
if __name__ == '__main__':
    main()
# === DO NOT modify the code above ===